home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / BlindAlleys.dxr / Internal_5_tableau cards.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  8.6 KB  |  255 lines

  1. property spriteNum, row, motion, location, fp
  2. global tableau, stock, equal, getlist, godlist, reserve, currentsel, dimpos, extras, points, foundation
  3.  
  4. on beginSprite me
  5.   row = determinerow()
  6.   location = sprite(spriteNum).loc
  7.   if not objectp(tableau[row]) then
  8.     tableau.addProp(row, new(script("card pile")))
  9.   end if
  10.   if tableau[row].getcardcount() < 1 then
  11.     sprite(spriteNum).member = member(stock.cards[1].rank & "_" & stock.cards[1].suit, "playing cards")
  12.     stock.cards.deleteAt(1)
  13.     tableau[row].addCard(spriteNum)
  14.   end if
  15.   candd = [#one: 12, #two: 28, #thr: 44, #fou: 60, #fiv: 76, #six: 92]
  16.   fp = candd[row]
  17. end
  18.  
  19. on determinerow me
  20.   if (spriteNum >= 12) and (spriteNum <= 25) then
  21.     return #one
  22.   else
  23.     if (spriteNum >= 28) and (spriteNum <= 41) then
  24.       return #two
  25.     else
  26.       if (spriteNum >= 44) and (spriteNum <= 57) then
  27.         return #thr
  28.       else
  29.         if (spriteNum >= 60) and (spriteNum <= 73) then
  30.           return #fou
  31.         else
  32.           if (spriteNum >= 76) and (spriteNum <= 89) then
  33.             return #fiv
  34.           else
  35.             if (spriteNum >= 92) and (spriteNum <= 105) then
  36.               return #six
  37.             end if
  38.           end if
  39.         end if
  40.       end if
  41.     end if
  42.   end if
  43. end
  44.  
  45. on mouseDown me
  46.   if sprite(spriteNum).member <> member("empty", "playing cards") then
  47.     puppetSound(3, member("pick card", "100GPak Generic SFX"))
  48.     if spriteNum = tableau[row].getlastcard().spnum then
  49.       sprite(spriteNum).locZ = spriteNum + 1000
  50.       getlist = tableau[row]
  51.       motion = timeout(string(spriteNum)).new(5, #moving, me)
  52.     else
  53.       if sprite(spriteNum).member.name <> "backofcard" then
  54.         runcheck()
  55.       end if
  56.     end if
  57.   else
  58.     sendSprite(spriteNum - 1, #mouseDown)
  59.   end if
  60. end
  61.  
  62. on moving me
  63.   if the mouseDown then
  64.     sprite(spriteNum).loc = the mouseLoc
  65.   else
  66.     if the mouseUp then
  67.       motion.forget()
  68.       sprite(spriteNum).locZ = spriteNum
  69.       abort()
  70.     end if
  71.   end if
  72. end
  73.  
  74. on mouseUp me
  75.   if equal then
  76.     puppetSound(3, member("pick card", "100GPak Generic SFX"))
  77.     if extras.count = 0 then
  78.       sprite(currentsel).member = member(sprite(spriteNum).member.name, "playing cards")
  79.       godlist.addCard(currentsel)
  80.       tableau[row].cards.deleteOne(tableau[row].getlastcard())
  81.       sprite(spriteNum).member = member("empty", "playing cards")
  82.       sprite(spriteNum).loc = location
  83.     else
  84.       if extras.count > 0 then
  85.         extras.sort()
  86.         repeat with i = 0 to extras.count - 1
  87.           sprite(currentsel + i).member = member(sprite(the clickOn + i).member.name, "playing cards")
  88.           sprite(the clickOn + i).member = member("empty", "playing cards")
  89.           godlist.addCard(currentsel + i)
  90.           tableau[row].cards.deleteAt(tableau[row].getcardcount())
  91.           sprite(the clickOn + i).loc = sprite(the clickOn + i).location
  92.         end repeat
  93.         if tableau[row].getcardcount() > 0 then
  94.           if sprite(spriteNum - 1).member.name = "backofcard" then
  95.             sprite(spriteNum - 1).member = member(reserve[row][1], "playing cards")
  96.             reserve[row].deleteAt(1)
  97.             tableau[row].addCard(spriteNum - 1)
  98.           end if
  99.         end if
  100.       end if
  101.     end if
  102.     if tableau[row].getcardcount() > 0 then
  103.       if extras.count = 0 then
  104.         if sprite(spriteNum - 1).member.name = "backofcard" then
  105.           sprite(spriteNum - 1).member = member(reserve[row][1], "playing cards")
  106.           reserve[row].deleteAt(1)
  107.           tableau[row].addCard(spriteNum - 1)
  108.         end if
  109.       else
  110.         if extras.count > 0 then
  111.           put the clickOn
  112.           if sprite(the clickOn - 1).member.name = "backofcard" then
  113.             sprite(the clickOn - 1).member = member(reserve[row][1], "playing cards")
  114.             reserve[row].deleteAt(1)
  115.             tableau[row].addCard(the clickOn - 1)
  116.           end if
  117.         end if
  118.       end if
  119.     end if
  120.     extras.deleteAll()
  121.     getlist = VOID
  122.     godlist = VOID
  123.     equal = 0
  124.     if tableau[row].getcardcount() = 0 then
  125.       sprite(fp).member = member("empty", "playing cards")
  126.     end if
  127.     if objectp(foundation[sprite(currentsel).row]) then
  128.       points = points + 10
  129.     end if
  130.     checkwin()
  131.     repeat with u in [26, 42, 58, 74, 90, 106]
  132.       if tableau[sprite(u).row].getcardcount() > 0 then
  133.         sprite(u).loc = sprite(tableau[sprite(u).row].getlastcard().spnum).location
  134.         next repeat
  135.       end if
  136.       sprite(u).loc = sprite(u).location
  137.     end repeat
  138.     currentsel = 0
  139.   else
  140.     if not equal then
  141.       puppetSound(3, member("drop card", "100GPak Generic SFX"))
  142.       sprite(spriteNum).loc = location
  143.       getlist = VOID
  144.       if extras > 0 then
  145.         repeat with i = 1 to extras.count
  146.           sprite(extras[i]).loc = sprite(extras[i]).location
  147.         end repeat
  148.         extras.deleteAll()
  149.       end if
  150.     end if
  151.   end if
  152.   if tableau[row].getcardcount() = 0 then
  153.     sprite(fp - 1).member = member("empty", "playing cards")
  154.   end if
  155.   repeat with u in [26, 42, 58, 74, 90, 106]
  156.     if tableau[sprite(u).row].getcardcount() > 0 then
  157.       sprite(u).loc = sprite(tableau[sprite(u).row].getlastcard().spnum).location
  158.       next repeat
  159.     end if
  160.     sprite(u).loc = sprite(u).location
  161.   end repeat
  162.   if tableau[row].getcardcount() = 0 then
  163.     sprite(fp).member = member("empty", "playing cards")
  164.   end if
  165. end
  166.  
  167. on runcheck me
  168.   ass = 0
  169.   repeat with i = 1 to tableau[row].getcardcount()
  170.     if tableau[row].cards[i].spnum = spriteNum then
  171.       ss = i
  172.       dimpos = i
  173.       exit repeat
  174.     end if
  175.   end repeat
  176.   tt = ss + 1
  177.   repeat with ret = tt to tableau[row].getcardcount()
  178.     if tableau[row].cards[ret].suitcolor = tableau[row].cards[ret - 1].suitcolor then
  179.       exit repeat
  180.     end if
  181.     if tableau[row].cards[ret].rankvalue <> (tableau[row].cards[ret - 1].rankvalue - 1) then
  182.       exit repeat
  183.     end if
  184.     if ret <> tableau[row].getcardcount() then
  185.       next repeat
  186.     end if
  187.     ass = 1
  188.   end repeat
  189.   if ass then
  190.     getlist = tableau[sprite(tableau[row].cards[i].spnum).row]
  191.     sprite(tableau[row].cards[ss].spnum).locZ = tableau[row].cards[ss].spnum + 1000
  192.     sprite(tableau[row].cards[ss].spnum).motion = timeout(string(row) && string(spriteNum)).new(5, #moving, sprite(tableau[row].cards[ss].spnum))
  193.     extras.add(spriteNum)
  194.     repeat with ret = tt to tableau[row].getcardcount()
  195.       sprite(tableau[row].cards[ret].spnum).locZ = tableau[row].cards[ret].spnum + 1000
  196.       sprite(tableau[row].cards[ret].spnum).motion = timeout(string(row) && string(tableau[row].cards[ret].spnum)).new(1, #keepintouch, sprite(tableau[row].cards[ret].spnum))
  197.       extras.add(tableau[row].cards[ret].spnum)
  198.     end repeat
  199.   end if
  200.   repeat with u in [26, 42, 58, 74, 90, 106]
  201.     if tableau[sprite(u).row].getcardcount() = 0 then
  202.       temp = [12, 28, 44, 60, 76, 92]
  203.       temp2 = [26, 42, 58, 74, 90, 106]
  204.       ass = temp[temp2.findPos(u)]
  205.       sprite(u).loc = sprite(ass).location
  206.       next repeat
  207.     end if
  208.     sprite(u).loc = tableau[sprite(u).row].getlastcard().location
  209.   end repeat
  210. end
  211.  
  212. on keepintouch me
  213.   if the mouseDown then
  214.     sprite(spriteNum).loc = point(the mouseH, sprite(spriteNum - 1).locV + 25)
  215.   else
  216.     if the mouseUp then
  217.       sprite(spriteNum).locZ = spriteNum
  218.       motion.forget()
  219.       abort()
  220.     end if
  221.   end if
  222. end
  223.  
  224. on backCardEQ me
  225.   if spriteNum <> fp then
  226.     if (sprite(spriteNum - 1).member.name <> "backofcard") and (sprite(spriteNum - 1).member.name <> "empty") then
  227.       if (getValue(sprite(spriteNum).member.name) = (getValue(sprite(spriteNum - 1).member.name) - 1)) and (getSuitCo(sprite(spriteNum).member.name) <> getSuitCo(sprite(spriteNum - 1).member.name)) then
  228.         repeat with shit = spriteNum - 1 to spriteNum - 1
  229.           repeat with cakes = 1 to tableau.count
  230.             if tableau[cakes].getcardcount() = 0 then
  231.               next repeat
  232.             end if
  233.             if (getValue(sprite(shit).member.name) = (getValue(sprite(tableau[cakes].getlastcard().spnum).member.name) - 1)) and (getSuitCo(sprite(shit).member.name) <> getSuitCo(sprite(tableau[cakes].getlastcard().spnum).member.name)) and not getduplicateme(tableau[cakes].getlastcard().spnum) then
  234.               return 1
  235.               exit
  236.             end if
  237.           end repeat
  238.         end repeat
  239.       else
  240.         sendSprite(spriteNum - 1, #backCardEQ)
  241.       end if
  242.     end if
  243.   end if
  244.   return 0
  245. end
  246.  
  247. on getduplicateme me, argu
  248.   if (sprite(spriteNum - 1).member.name <> "empty") and (sprite(spriteNum - 1).member.name <> "backofcard") then
  249.     if (getValue(sprite(spriteNum - 1).member.name) = getValue(sprite(argu).member.name)) and (getSuitCo(sprite(spriteNum - 1).member.name) = getSuitCo(sprite(argu).member.name)) then
  250.       return 1
  251.     end if
  252.   end if
  253.   return 0
  254. end
  255.